package com.mazaiting.spring.bean;

import java.util.Objects;

/***
 * 抽象 Bean 定义
 * @author mazaiting
 * @datetime 2021/11/18 13:35  
 */
public abstract class AbstractBeanDefinition implements BeanDefinition{
    /**
     * 默认作用域
     */
    public static final String SCOPE_DEFAULT = "";
    /**
     * 类字节码
     */
    private Class<?> clazz;
    /**
     * 作用域
     */
    private String scope;

    public AbstractBeanDefinition() {

    }

    public void setClazz(Class<?> clazz) {
        this.clazz = clazz;
    }

    @Override
    public Class<?> getClazz() {
        return clazz;
    }

    @Override
    public String getScope() {
        return scope;
    }

    @Override
    public void setScope(String scope) {
        this.scope = scope;
    }

    @Override
    public boolean isSingleton() {
        return Objects.equals(SCOPE_DEFAULT, scope) || Objects.equals(SCOPE_SINGLETON, scope);
    }

    @Override
    public boolean isPrototype() {
        return Objects.equals(SCOPE_PROTOTYPE, scope);
    }
}
